#!/usr/bin/env python
#
#       Outgoing.py
#       
#       Copyright 2009 Ben Davis <its.hip@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

class Packet:
    """Base-class for packets. Simply put in the info you need to send
    and create a matching class in the Client Incoming.py which acts upon
    the data on a __call__"""
    def __init__(self):
        pass

class AddPlayer(Packet):
    """Add a player to the game"""
    def __init__(self, player):
        self.player = player

class AddShip(Packet):
    """Add a ship to player"""
    def __init__(self, ship):
        self.ship = ship

class Fire(Packet):
    """Return the results of a ship firing"""
    def __init__(self, ship, weapon, damaged):
        self.ship = ship.key()
        self.player = ship.player
        self.weapon = weapon
        self.damaged = damaged

class Message(Packet):
    def __init__(self, message):
        self.message = message

class NewTurn(Packet):
    """Signal a new turn to the clients. Here player is a key"""
    def __init__(self, player):
        self.player = player

class Orders(Packet):
    def __init__(self, ship, orders):
        self.ship = ship.key()
        self.player = ship.player
        self.orders = orders

class RemovePlayer(Packet):
    """Remove a player from the game"""
    def __init__(self, player):
        self.player = player.key()
        
class Said(Packet):
    def __init__(self, player, text):
        self.player = player.key()
        self.text = text

class Sync(Packet):
    """Send all players"""
    def __init__(self, player, players, map):
        self.players = players
        self.player = player.key()
        self.map = map

class Connect(Packet):
    """Go somewhere else!"""
    def __init__(self, server, port):
        self.server = server
        self.port = int(port)
    
class Login(Packet):
    """OH HI I PLAY UR GAEMS"""
    def __init__(self, username, password):
        self.username = username
        self.password = password
        
class Logout(Packet):
    """KTHXBAI"""
    def __init__(self):
        self.handshake = "lol"

class Register(Packet):
    """Play with me =C"""
    def __init__(self):
        self.handshake = "lol"
class Unregister(Packet):
    """FINE DON'T"""
    def __init__(self):
        self.handshake = "lol"
        #Do these need variables to load them? :/
